 //빌딩 부시기.

#include <iostream>
#include <fstream>

using namespace std;

int check(int* array,int start_num,int B_num){
	
	int cnt = 0;
	for(int i =0; i<B_num+1; i++){
		if(array[start_num-1] <= array[i])
			cnt++;
	}

	return cnt*start_num;
}
int main(){
	ifstream fin;
	ofstream fout;

	fin.open("input");
	fout.open("output");
	int i = 0;
	int array[1000] = {0};
		
	int B_num[1000] = {0};
	
	fin>>B_num[0];
	
	for(i = 0; i<B_num[0]; i++){
		fin>>array[i];
		cout<<array[i]<<" ";
	}
	cout<<endl;
	int cnt = 0;
	int max= 0;
	
	for(i=0; i<B_num[0]; i++){
		B_num[i+1] = check(array,array[i],B_num[0]);
	}

	max = B_num[1];
	for(i=0; i<6; i++){
		cout<<B_num[i+1]<<" ";

		if(max <B_num[i+i])
			max = B_num[i+1];
	}
	cout<<endl;
	cout<<"max = "<<max<<endl;
	return 0;

		
}
